package ch.bfh.mobicomp.soda2.barometer;

import java.io.Serializable;

import android.app.Activity;
import android.app.Service;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class SharedPreferencesManager implements Serializable {
	
	
	private static final long serialVersionUID = 1L;
	public static final String KEY_BAROMETER_CHANGED = "Barometer has changed";
	public static final String KEY_BAROMETER_VALUE = "Barometer value";
	private SharedPreferences preferences;
	private SharedPreferences.Editor editor;
	
	
	public SharedPreferencesManager(Service service)
	{
		preferences =  service.getSharedPreferences("Barometer", Context.MODE_PRIVATE);
		editor = preferences.edit();
	}
	
	public void setChange(boolean hasChanged)
	{
		editor.putBoolean(KEY_BAROMETER_CHANGED, hasChanged);
	}
	
	public boolean getChange()
	{
		return preferences.getBoolean(KEY_BAROMETER_CHANGED, false);
	}
	
	public void setValue(float value) {
		editor.putFloat(KEY_BAROMETER_VALUE, value);		
	}
	
	public float getValue()
	{
		return preferences.getFloat(KEY_BAROMETER_VALUE, 0);
	}
	
}
